package cn.haocxy.jfm.gui;

import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import cn.haocxy.jfm.file.FileIcons;

/**
 * 图标背景
 * @author 蔡心宇
 *
 */
class IconBackground {

	private static final double ARC_SIZE = 5;

	private static final Color FILL = Color.LIGHTSTEELBLUE;

	private static final Color STROKE_NORMAL = FILL;

	private static final Color STROKE_HOVER = Color.LIGHTSKYBLUE;

	private static final double STROKE_WIDTH = 2;

	private final Rectangle iconBack = new Rectangle();
	
	public IconBackground() {
		iconBack.setWidth(FileIcons.ICONSIZE);
		iconBack.setHeight(FileIcons.ICONSIZE);
		iconBack.setFill(FILL);
		iconBack.setArcWidth(ARC_SIZE);
		iconBack.setArcHeight(ARC_SIZE);
		iconBack.setStrokeWidth(STROKE_WIDTH);
		iconBack.setStroke(STROKE_NORMAL);
		iconBack.setVisible(false);
	}
	
	public void update(boolean isHover) {
		if (isHover) {
			iconBack.setStroke(STROKE_HOVER);
		} else {
			normal();
		}
		iconBack.setVisible(true);
	}
	
	public void hide() {
		iconBack.setVisible(false);
	}
	
	public void normal() {
		iconBack.setStroke(STROKE_NORMAL);
	}
	
	public Node toNode() {
		return iconBack;
	}
}
